

/**
 * @author ghp
 * @title
 */
class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length, n = matrix[0].length;
        int row = 0, col = n - 1;
        while (row < m && col >= 0) {
            if (matrix[row][col] == target) {
                return true;
            }
            if (matrix[row][col] > target) {
                // 目标值比当前坐标值要小，则向左逼近
                --col;
            } else {
                // 目标值比当前坐标值要大，则向下逼近
                ++row;
            }
        }
        return false;
    }
}